home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4717 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can main() function be called?
  5. Date: Tue, 06 Feb 96 15:17:30 GMT
  6. Organization: none
  7. Message-ID: <823619850snz@genesis.demon.co.uk>
  8. References: <823183263.118@fountain.demon.co.uk> <4f1mv0$2fd@cloner4.netcom.com> <4f6n77$e53@library.erc.clarkson.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4f6n77$e53@library.erc.clarkson.edu>
  15.            koglerje@craft.camp.clarkson.edu "Mountain (jimbo" writes:
  16.  
  17. >Mike Rosenblyum (rozen@ix.netcom.com) wrote:
  18. >: I think that it cannot be done, I see no reasonalbe way how main()
  19. >: could be called more than once.
  20. >
  21. >
  22. >:    What is your thoughts on this?
  23. >
  24. >
  25. >Sure you can call main() again, well kindof,  just uses setjmp()
  26. >and longjmp() just put a setjump() call inside main() like:
  27. >
  28. >int main()
  29. >{
  30. >  setjmp(jmp_buf hi);
  31. >  ..
  32. >}
  33.  
  34. However that isn't calling main, it is simply returning to an existing
  35. invocation of it. You can call main with a normal function call such as
  36.  
  37.     main();
  38.  
  39. in your program. That is perfectly legal and well defined by the C language.
  40.  
  41. -- 
  42. -----------------------------------------
  43. Lawrence Kirby | fred@genesis.demon.co.uk
  44. Wilts, England | 70734.126@compuserve.com
  45. -----------------------------------------
  46.